package cn.cerc.sample.config;

import cn.cerc.db.core.IHandle;
import cn.cerc.db.core.ISession;
import cn.cerc.db.core.Variant;
import cn.cerc.mis.core.WebService;
import cn.cerc.mis.security.Permission;
import cn.cerc.mis.security.SecurityService;

@WebService(describe = "用户登录服务")
@Permission(Permission.GUEST)
public class LoginSystem implements SecurityService {

    @Override
    public boolean initSession(ISession session, String token) {
        if (token == null)
            return false;
        session.setProperty(ISession.TOKEN, token);
        session.setProperty(ISession.CORP_NO, Session.DefaultCorpNo);
        session.setProperty(ISession.USER_CODE, Session.DefaultUserCode);
        return true;
    }

    @Override
    public String getPermissions(ISession session) {
        String token = session.getToken();
        if (token == null)
            return null;
        else
            return Permission.ADMIN;
    }

    @Override
    public void loadPermission(IHandle handle, Variant outParam) {

    }

    @Override
    public String getSystemUserToken(IHandle handle, String corpNo, String machineCode) {
        // TODO Auto-generated method stub
        return null;
    }

}
